using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RetailAnalytic.SR;
namespace RetailAnalytic.Core
{
    public partial class frmTemplate : Form
    {
        const int WM_NCHITTEST = 0x0084;
        const int HTCAPTION = 2; 
        public frmTemplate()
        {
            InitializeComponent();
            SetGuiAppearance();
        }
        private void SetGuiAppearance()
        {
            pbHeader.BackgroundImage = RetailAnalytic.SR.ImagesLibrary.GetImageByName("RAMain");
        }
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_NCHITTEST)
            {
                int x = m.LParam.ToInt32() & 0x0000FFFF;
                int y = m.LParam.ToInt32() >> 16;
                Point mousePosition = PointToClient(new Point(x, y));
                if (GetChildAtPoint(mousePosition) == pbHeader)
                {
                    m.Result = (IntPtr)HTCAPTION;
                    return;
                }
            }
            base.WndProc(ref m);
        }
    }
    public class pbHeaderEx : PictureBox
    {
        const int WM_NCHITTEST = 0x0084;
        const int HTTRANSPARENT = -1;
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_NCHITTEST)
                m.Result = (IntPtr)HTTRANSPARENT;
            else
                base.WndProc(ref m);
        } 
    }
}